/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : freertos.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
  .name = "defaultTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for RCTask */
osThreadId_t RCTaskHandle;
const osThreadAttr_t RCTask_attributes = {
  .name = "RCTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for CAN1SendTask */
osThreadId_t CAN1SendTaskHandle;
const osThreadAttr_t CAN1SendTask_attributes = {
  .name = "CAN1SendTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for LocateMotorTask */
osThreadId_t LocateMotorTaskHandle;
const osThreadAttr_t LocateMotorTask_attributes = {
  .name = "LocateMotorTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for MasterTask */
osThreadId_t MasterTaskHandle;
const osThreadAttr_t MasterTask_attributes = {
  .name = "MasterTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for CAN2SendTask */
osThreadId_t CAN2SendTaskHandle;
const osThreadAttr_t CAN2SendTask_attributes = {
  .name = "CAN2SendTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for RcSemBinary */
osSemaphoreId_t RcSemBinaryHandle;
const osSemaphoreAttr_t RcSemBinary_attributes = {
  .name = "RcSemBinary"
};

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

void StartDefaultTask(void *argument);
void RcData_Task(void *argument);
void CAN1Send_Control(void *argument);
void LocateMotor_Task(void *argument);
void Master_Control_Task(void *argument);
void CAN2Send_Control(void *argument);

void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */

/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* Create the semaphores(s) */
  /* creation of RcSemBinary */
  RcSemBinaryHandle = osSemaphoreNew(1, 1, &RcSemBinary_attributes);

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* creation of defaultTask */
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

  /* creation of RCTask */
  RCTaskHandle = osThreadNew(RcData_Task, NULL, &RCTask_attributes);

  /* creation of CAN1SendTask */
  CAN1SendTaskHandle = osThreadNew(CAN1Send_Control, NULL, &CAN1SendTask_attributes);

  /* creation of LocateMotorTask */
  LocateMotorTaskHandle = osThreadNew(LocateMotor_Task, NULL, &LocateMotorTask_attributes);

  /* creation of MasterTask */
  MasterTaskHandle = osThreadNew(Master_Control_Task, NULL, &MasterTask_attributes);

  /* creation of CAN2SendTask */
  CAN2SendTaskHandle = osThreadNew(CAN2Send_Control, NULL, &CAN2SendTask_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_EVENTS */
  /* add events, ... */
  /* USER CODE END RTOS_EVENTS */

}

/* USER CODE BEGIN Header_StartDefaultTask */
/**
  * @brief  Function implementing the defaultTask thread.
  * @param  argument: Not used
  * @retval None
  */
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
  /* USER CODE BEGIN StartDefaultTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartDefaultTask */
}

/* USER CODE BEGIN Header_RcData_Task */
/**
* @brief Function implementing the RCTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_RcData_Task */
__weak void RcData_Task(void *argument)
{
  /* USER CODE BEGIN RcData_Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END RcData_Task */
}

/* USER CODE BEGIN Header_CAN1Send_Control */
/**
* @brief Function implementing the CAN1SendTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_CAN1Send_Control */
__weak void CAN1Send_Control(void *argument)
{
  /* USER CODE BEGIN CAN1Send_Control */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END CAN1Send_Control */
}

/* USER CODE BEGIN Header_LocateMotor_Task */
/**
* @brief Function implementing the LocateMotorTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LocateMotor_Task */
__weak void LocateMotor_Task(void *argument)
{
  /* USER CODE BEGIN LocateMotor_Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END LocateMotor_Task */
}

/* USER CODE BEGIN Header_Master_Control_Task */
/**
* @brief Function implementing the MasterTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_Master_Control_Task */
__weak void Master_Control_Task(void *argument)
{
  /* USER CODE BEGIN Master_Control_Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END Master_Control_Task */
}

/* USER CODE BEGIN Header_CAN2Send_Control */
/**
* @brief Function implementing the CAN2SendTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_CAN2Send_Control */
__weak void CAN2Send_Control(void *argument)
{
  /* USER CODE BEGIN CAN2Send_Control */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END CAN2Send_Control */
}

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */

/* USER CODE END Application */

